#ifndef __BLENDER_FILTER_H__
#define __BLENDER_FILTER_H__

#include <highgui.h>
#include <cv.h>
#include <iostream>

#include <Filter.h>
#include <Picture.h>

/* BlenderFilter class
 * inherits the interface of Filter so it has a functionality
 * of displaying image to the screen and interract with user;
 * the main and only responsibility of this class is to execute the
 * blending algorithm on backgorounf and a foreground.
 * The blender can be called several times, each time with a modified
 * position of the blended foreground
 */
class BlenderFilter : public Filter {
    public:
        /* BlenderFilter c'tor
         * Gets the background picture and to matrices: foreground ROI and
         * it's mask part.
         */
        BlenderFilter(const Picture& bg, const vector <cv::Mat> fg);
        ~BlenderFilter();
        
        /* show the blended image */
        virtual bool refresh(cv::Mat& image) const;
        /* refine the blending according to moreData which points
         * to cv::Point object that contains coordinate to the TL value of the ROI. */
        virtual int nextIter(void* moreData=0);
        virtual boost::shared_ptr<Picture> exportPicture();
    private:
        const Picture& background;
        const vector <cv::Mat> foreground;

        cv::Mat blended;

        /* no default copy c'tors */
        BlenderFilter(const BlenderFilter& p); // no default copy c'tor
        BlenderFilter& operator=(const BlenderFilter& p); // no default copy c'tor
        
        bool initialized;
        bool init();
        void initMask();
        void destroy();
};


#endif // __BLENDER_FILTER_H__
